package com.jqr.activity.viewpagefragmentdemo.adapters;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.jqr.activity.viewpagefragmentdemo.R;

import java.util.ArrayList;
import java.util.List;

public class ViewPagerAdapter  extends RecyclerView.Adapter<ViewPagerAdapter.ViewPagerViewHolder> {
    private List<String> titles=new ArrayList<>();

    public ViewPagerAdapter(){

        titles.add("互联网+大学生");
        titles.add("电子设计大赛");
        titles.add("服务外包");
        titles.add("蓝桥杯");
        titles.add("中美创新创意大赛");
        titles.add("传智杯");
        titles.add("ICT");
        titles.add("软件杯大赛");
        titles.add("计算机技能大赛");
        titles.add("物联网技术大赛");
    }


    @NonNull
    @Override
    public ViewPagerViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {



        return new ViewPagerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_pager,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull ViewPagerViewHolder holder, int position) {
            holder.tvView.setText(titles.get(position));
    }

    @Override
    public int getItemCount() {
        return titles.size();
    }

    static class ViewPagerViewHolder extends RecyclerView.ViewHolder{
        TextView tvView;
        RelativeLayout relativeLayout;
        public ViewPagerViewHolder(@NonNull View itemView) {
            super(itemView);


            relativeLayout=itemView.findViewById(R.id.container);

            tvView=itemView.findViewById(R.id.tvView);
        }
    }
}
